﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;

namespace TMTemplate
{
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			InitializeComponent();
			VisualStateManager.GoToState(this, "Loading", false);
			VisualStateGroup.CurrentStateChanged +=new System.EventHandler<System.Windows.VisualStateChangedEventArgs>(VisualStateGroup_CurrentStateChanged);
			Loaded +=new System.Windows.RoutedEventHandler(MainPage_Loaded);
		}
		
		private void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
		{
			foreach (UriMapping urimapping in (pageTransition.contentFrame.UriMapper as UriMapper).UriMappings)
			{
				if (System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString().Contains("#" + urimapping.Uri.ToString()))
					Splash.Storyboard.Completed += new EventHandler(Storyboard_Completed);
			}
		}

		void Storyboard_Completed(object sender, EventArgs e)
		{
			VisualStateManager.GoToState(this, "Normal", true);
		}

		private void VisualStateGroup_CurrentStateChanged(object sender, System.Windows.VisualStateChangedEventArgs e)
		{
			if (e.NewState.Name == "Normal") 
            {
				//
            }
		}
	}
}